import threading

list1 = [0,1,2,3,4,5,6,7,8,9]

mutex = threading.Lock()


def read(index):
    mutex.acquire()
    if index >= len(list1):
        print("越界:", index)
        mutex.release()
        return
    print("num:", list1[index])
    mutex.release()


if __name__ == '__main__':
    for i in range(30):
        t = threading.Thread(target=read, args=(i,))
        t.start()
